#include "student.h"

#include <QDebug>

Student::Student()
{

}


//构造函数
Student::Student(QString name,QString sno,QString sex,QString age,QString college,QList<QString> intrests)
{
    this->name = name;
    this->sno = sno;
    this->sex = sex;
    this->age = age;
    this->college = college;
    this->intrests = intrests;
}


//toString
QString Student::toString()
{
    QString content = "";
    content.append(this->name+" ").append(this->sno+" ").append(this->sex+" ").append(this->age+" ").append(this->college+" ");

    for(int i = 0;i<this->intrests.length();i++)
    {
        content.append(this->intrests.at(i)+" ");
    }
    content = content.trimmed();
    //qDebug()<<"content = "<<content<<endl;
    return content;
}


//toStudent
Student Student::getStuFromString(QString content)
{
    QList<QString> infoList = content.split(" ");
    Student stu;
    stu.setName(infoList.at(0));
    stu.setSno(infoList.at(1));
    stu.setSex(infoList.at(2));
    stu.setAge(infoList.at(3));
    stu.setCollege(infoList.at(4));

    QList<QString> ins;
    for(int i = 5;i<infoList.length();i++)
    {
        ins.append(infoList.at(i));
    }


    stu.setIntrests(ins);
   // qDebug()<<"ins="<<ins<<",name="<<stu.getName()<<endl;
   // qDebug()<<stu.toString()<<endl;
    return stu;
}

//setter,  &  getter
void Student::setName(QString name)
{
    this->name = name;
}
QString Student::getName()
{
    return this->name;
}

void Student::setSno(QString sno)
{
    this->sno = sno;
}
QString Student::getSno()
{
    return this->sno;
}

void Student::setSex(QString sex)
{
    this->sex = sex;
}
QString Student::getSex()
{
    return sex;
}
void Student::setAge(QString age)
{
    this->age = age;
}
QString Student::getAge()
{
    return this->age;
}

void Student::setCollege(QString college)
{
    this->college = college;
}

QString Student::getCollege()
{
    return this->college;
}

void Student::setIntrests(QList<QString> intrests)
{
    this->intrests = intrests;
}

QList<QString> Student::getIntrests()
{
    return this->intrests;
}
